/**业务管理流程平台版本1.0,生成时间:2017-04-13 13:16:48**/
package com.xbdun.dao.bmp.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

import com.xbdun.dao.bmp.entity.XbdunSysOrgMenusDo;
import com.xbdun.dao.bmp.provider.SysOrgMenusSqlProvider;


/**
 * 企业被授权的菜单项
 * @author 张国涛
 * @2017-04-13 13:16:48
 */
@Mapper
public interface SysOrgMenusMapper{

	/**
	 * 根据主键获取对象
	 * @return
	 */
	@Select("SELECT * FROM xbdun_sys_org_menus where id=#{id}")
	public XbdunSysOrgMenusDo getXbdunSysOrgMenusById(@Param("id")long id);
	
	/**
	 * 新增
	 * @param XbdunSysOrgMenusDo 企业被授权的菜单项
	 */
	@Insert("INSERT INTO xbdun_sys_org_menus(orgCode,code) VALUES(#{a.orgCode},#{a.code})")
	@SelectKey(statement="SELECT LAST_INSERT_ID() AS ID", before = false, keyProperty = "a.id", resultType = Long.class)
	public Long addXbdunSysOrgMenus(@Param("a")XbdunSysOrgMenusDo xbdunSysOrgMenusDo);
	
	/**
	 * 删除数据根据主键
	 * @param id
	 */
	@Delete("DELETE FROM xbdun_sys_org_menus WHERE id = #{id}")
	public void delXbdunSysOrgMenusById(@Param("id")long id);
	
	/**
	 * 判断是否存在,不为null则是存在
	 * @param param
	 * @return Long
	 */
	@SelectProvider(type=SysOrgMenusSqlProvider.class,method="existSql")
	public Long existXbdunSysOrgMenus(@Param("param")Map<String,Object> param);
	/**
	 * 动态更新参数,参数中Map可以必须跟Key为Where的更新条件<br/>
	 * <pre>
	 * 	例如：
	 *  Map<String,Object> setting = new HashMap<String,Object>();
	 *  setting.put("email", "360730440@qq.com");
	 *
	 *  Map<String,Object> where = new HashMap<String,Object>();
	 *  where.put("userId", "1222");
	 * </pre>
	 * Map的key值就是数据库字段<br/>
	 * Map的value就是值
	 */
	@UpdateProvider(type=SysOrgMenusSqlProvider.class,method="updateDynXbdunSysOrgMenusSql")
	public void updateDynXbdunSysOrgMenus(@Param("param")Map<String,Object> param,@Param("_where")Map<String,Object> where);
	
	//------------------------//start分页查询--------------------------------------
	/**
	 * 分页查询 
	 * <pre>
	 * 	例如：
	 *  Map<String,Object> where = new HashMap<String,Object>();
	 *  param.put("orderby", "param.name,param age desc");
	 * </pre>
	 * @param _where where条件，现在支持And条件类型
	 * @param orderBy 排序条件
	 * @param pageNum 当前索引页
	 * @param numPerPage 每页显示条数
	 * @return
	 */
	@SelectProvider(type=SysOrgMenusSqlProvider.class,method="queryPagerSql")
	public List<XbdunSysOrgMenusDo> queryPager(@Param("_where")Map<String,Object> where,@Param("_orderby")String orderBy,@Param("pageNum")int pageNum,@Param("numPerPage")int numPerPage);
	
	/**
	 * 分页查询返回总数量
	 * <pre>
	 * 	例如：
	 *  Map<String,Object> where = new HashMap<String,Object>();
	 *  param.put("orderby", "param.name,param age desc");
	 * </pre>
	 * @param where 参数为where约束参数
	 * @return
	 */
	@SelectProvider(type=SysOrgMenusSqlProvider.class,method="queryPagerCountSql")
	public Long queryPagerCount(@Param("_where")Map<String,Object> where);
	//-------------------------//end--------------------------------------------

	/**
	 * 新增企业授权菜单
	 * @param orgCode
	 * @param addCodes
	 */
	@InsertProvider(type=SysOrgMenusSqlProvider.class,method="addOrgMenusSql")
	public void addOrgMenus(@Param("orgCode")Long orgCode, @Param("addCodes")List<Long> addCodes);

	/**
	 * 删除企业授权菜单
	 * @param xbdunSysOrgMenusDo
	 * @param cancelCodes 
	 */
	@DeleteProvider(type=SysOrgMenusSqlProvider.class,method="deletePowerUserSpecSql")
	public void deletePowerUserSpec(@Param("orgCode")Long orgCode, @Param("cancelCodes")List<Long> cancelCodes);
	@DeleteProvider(type=SysOrgMenusSqlProvider.class,method="deletePowerUserMenuSql")
	public void deletePowerUserMenu(@Param("orgCode")Long orgCode, @Param("cancelCodes")List<Long> cancelCodes);
	@DeleteProvider(type=SysOrgMenusSqlProvider.class,method="deletePowerRoleDepartSql")
	public void deletePowerRoleDepart(@Param("orgCode")Long orgCode, @Param("cancelCodes")List<Long> cancelCodes);
	@DeleteProvider(type=SysOrgMenusSqlProvider.class,method="deleteOrgMenusSql")
	public void deleteOrgMenus(@Param("orgCode")Long orgCode, @Param("cancelCodes")List<Long> cancelCodes);

	
}